package com.collection.treesets;

import java.util.TreeSet;

public class RemoveAllElementsFromTreeSetExample {
	public static void main(String[] args) {
		 
	    //create object of TreeSet
	    TreeSet tSet = new TreeSet();
	   
	    //add elements to TreeSet object
	    tSet.add(new Integer("1"));
	    tSet.add(new Integer("2"));
	    tSet.add(new Integer("3"));
	   
	    System.out.println("TreeSet before removal : " + tSet);
	   
	    /*
	      To remove all elements from Java TreeSet or to clear TreeSet object use,
	      void clear() method.
	      This method removes all elements from TreeSet.
	    */
	   
	    tSet.clear();
	    System.out.println("TreeSet after removal : " + tSet);
	   
	    /*
	      To check whether TreeSet contains any elements or not use
	      boolean isEmpty() method.
	      This method returns true if the TreeSet does not contains any elements
	      otherwise false.
	    */
	   
	    System.out.println("Is TreeSet empty ? " + tSet.isEmpty());    
	   
	    /*
	      Please note that removeAll method of Java TreeSet class can also be
	      used to remove all elements from TreeSet object.
	    */
	  }
}
